<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
	pageEncoding="ISO-8859-1"%>
<%@ taglib prefix='c' uri='http://java.sun.com/jstl/core_rt'%>
<%@taglib uri="http://www.springframework.org/tags/form" prefix="form"%>
<%@ page
	import="org.springframework.security.core.AuthenticationException"%>
<!DOCTYPE html>
<html lang="pl">
<head>
<meta charset="utf-8" />
<style type="text/css">
.promoteZ {
	z-index: 20036 !important; /* Dialog z-index is 1006*/
}
</style>


<style type="text/css">
</style>
<title>Login</title>

<link rel="stylesheet" type="text/css"
	href=${pageContext.servletContext.contextPath}/static/css/logreg-style.css />
<link rel="stylesheet" type="text/css"
	href=${pageContext.servletContext.contextPath}/static/css/logreg-form.css />
<link rel="stylesheet" type="text/css"
	href=${pageContext.servletContext.contextPath}/static/css/jquery-ui-1.8.14.custom.css />
<script type="text/javascript"
	src=${pageContext.servletContext.contextPath}/static/javascript/jquery-1.6.2.min.js></script>
<script type="text/javascript"
	src=${pageContext.servletContext.contextPath}/static/javascript/jquery-1.6.2.min.js></script>
<script type="text/javascript"
	src=${pageContext.servletContext.contextPath}/static/javascript/jquery-ui-1.8.16.custom.min.js></script>
<script type="text/javascript"
	src=${pageContext.servletContext.contextPath}/static/javascript/jquery.validate-1.5.5.min.js></script>
<script type="text/javascript"
	src=${pageContext.servletContext.contextPath}/static/javascript/scripts-1.0.js></script>
<script type="text/javascript"
	src=${pageContext.servletContext.contextPath}/static/javascript/ajaxupload-3.9.js></script>



<script type="text/javascript">
	function submitForm() {

		jQuery("form").submit();

	}
	
	

	  function onImportCompleteCallback(status, file, content) {
			grayScreen(false);
			var txt = content;
			if (txt.substring(0, 5) == "load:") {
				url = replaceAmp(txt.substring(5));
				grayScreen(true);
				jQuery("#New_Panel").load(url);
	            return;
	        }
			jQuery('#import_response').html(content);
			}
	  
	  function onSubmitCallback(file) {
			grayScreen(false);
			jQuery('#import_response').html("");
		}
	  
	  
	jQuery(document).ready(function() {
		
		grayScreen(false);
		 url = 'adminUploadgallerytab.do?id='+${id};
			uploadFile(jQuery("#import_button"), url, "file", onSubmitCallback, onImportCompleteCallback);

		
		
		jQuery("#editcarForm").validate({
			rules : {
				brand : {
					required : true

				},
				model : {
					required : true

				},
				year : {
					required : true,
					rangelength: [4,4],
					range: [1850,2012]
				},

				registNumber : {
					required : true
				},

				desc : {
					required : true
				},
				
				color : {
					required : true
				}

			},
			messages : {
				brand : {
					required : "Wymagane pole!"

				},
				model : {
					required : "Wymagane pole!"
					
				},
				year : {
					required : "Wymagane pole!",
					rangelength : "Wprowadz rocznik w formacie yyyy",
					range :"Wprowadz poprawny rocznik!"
					
				},

				registNumber : {
					required : "Wymagane pole!"
				},

				desc : {
					required : "Wymagane pole!"
				},
				color : {
					required : "Wymagane pole!"
				},
			},
			success : function(label) {
				label.html("&nbsp;").addClass("sprawdzony");
			},
			error : function(label) {
				alert("label");
			}

		});
	});
</script>
<style type="text/css">
.promoteZ {
	z-index: 20036 !important; /* Dialog z-index is 1006*/
}

label {
	width: 200px !important;
	float: left;
	display: inline;
	clear: none;
}

label.error {
	margin: 0;
	margin-left: 10px !important;
	float: left;
	background: none;
	color: red;
	padding-left: 15px;
	vertical-align: top;
}

p {
	clear: both;
}

label.sprawdzony {
	float: left;
	background: url("../static/images/sprawdzony.png") no-repeat 0px 0px;
	margin-left: 5px;
}
</style>
</head>
<body>
	<div id="header">

		<form:form class="cmxform" commandName="editcarForm" id="editcarForm"
			method="post" action="adminEditCar.do" style="width:700px;">
			<fieldset>
				<legend>Edytuj samochod</legend>
				<p>
					<form:label path="brand">Marka</form:label>
					<form:input path="brand" />
				</p>
				<p>
					<form:label path="model">Model</form:label>
					<form:input path="model" />
				</p>
				<p>
					<form:label path="year">Rocznik</form:label>
					<form:input path="year"
						onkeyup="this.value=this.value.replace(/\D/g,'')"
						required="required" number="true" />
				</p>
				<p>
					<form:label path="registNumber">Numery rejestracyjne</form:label>
					<form:input path="registNumber" />
				</p>
				<p>
					<form:label path="color">Kolor</form:label>
					<form:input path="color" />
				</p>
				<p>
					<form:label path="desc">Opis</form:label>
					<form:input path="desc" />
				</p>
				<label>Wczytaj zdjecie</label>
					<input type="button" id="import_button" value="Upload"/>
					<div id="import_response"></div>
				
				<p>
					<label style="color: red;">${message}</label><input type="submit"
						value="Zmien" />
			</fieldset>
			<input type="hidden" path="id" id="id" name="id" value="${car.id}" />
		</form:form>


		<a href="adminDeleteCar.do?id=${car.id}">Usun</a> <br>
		<br> <a href="adminListCars.do">Wroc</a>



	</div>

<div id="New_Panel"></div>

	<div id="masthead"
		style="background: url('static/images/images1.jpg') no-repeat; height: 400px; margin: auto;">
	</div>

	<div id="footer">
		<p>i to wszystko na razie jesli chodzi o te strone :)</p>
	</div>
	</div>
</body>
</html>